<?php
/**
 * Created by PhpStorm.
 * User: henryxi-mac
 * Date: 2015/4/15
 * Time: 20:50
 */
class Data_mod  extends CI_Model {
    var $name = "";
    var $phone = "";
    var $district = "";
    var $community = "";
    var $datetime = "";
    var $type = "";
    var $accept = 0;
    private $_date = "";


    function __construct()
    {
        parent::__construct();
        $this->load->database();
    }

    public function check_validation(){
        return true;
    }

    public function insert(){
        $this->db->insert("order", $this);
    }

    public function submit($accept){
        $this->name = $this->input->post("name");
        $this->phone = $this->input->post("phone");
        $this->district = $this->input->post("district");
        $this->community = $this->input->post("community");
        $this->type = $this->input->post("type");
        $this->accept = $accept;
        $this->datetime = date("Y-m-d H:i:s",time());
        if ($this->check_validation()) {
            $check = $this->db->get_where('order', array("phone" => $this->phone));
            $rs = $check->result();
            if (empty($rs)){
                $this->insert("order", $this);
                return true;
            //$error_msg = $this->db->_error_message();
            //var_dump($error_msg);exit();
            }else
            {
                return false;
            }

        }
    }

    public  function cmQuery($cm){
        $check = $this->db->get_where('community',$cm);
        $rs = $check->result();
        return $rs;
    }

    public function cm_list()
    {
    $check = $this->db->get_where('community');
    $rs = $check->result();
    return $rs;
    }

    public function  pvdata(){
        $rs = $this->db->get_where("pvuv")->result();
        return $rs;
    }

    public function mobileData(){
        $rs = $this->db->get_where("order")->result();
        return $rs;
    }

    public function share(){

    }
}